package xy.donate.android.ui.adapter;

import android.content.Intent;
import android.view.View;

import androidx.annotation.LayoutRes;
import androidx.recyclerview.widget.RecyclerView;

import com.chad.library.adapter.base.BaseQuickAdapter;
import com.chad.library.adapter.base.viewholder.BaseViewHolder;
import com.hjq.base.BaseAdapter;

import org.jetbrains.annotations.NotNull;

import xy.donate.android.R;
import xy.donate.android.entity.OrderBean;
import xy.donate.android.ui.activity.OrderDetailActivity;

public class OrderAdapter extends BaseQuickAdapter<OrderBean, BaseViewHolder> {

    public OrderAdapter(@LayoutRes int layout){
        super(layout);
    }

    @Override
    protected void convert(@NotNull BaseViewHolder baseViewHolder, OrderBean o) {
        baseViewHolder.setText(R.id.tv_name,o.getAddress().getRealName());
        baseViewHolder.setText(R.id.tv_address,o.getAddress().getDetailAddress());
        baseViewHolder.setText(R.id.tv_phone,o.getAddress().getPhoneNum());
        baseViewHolder.setText(R.id.tv_time,o.getTime());
        baseViewHolder.setText(R.id.tv_order_no,o.getOrderNo());
        baseViewHolder.getView(R.id.tv_order_detail).setOnClickListener(view -> {
            Intent intent = new Intent(getContext(), OrderDetailActivity.class);
            intent.putExtra("OrderNo",o.getOrderNo());
            getContext().startActivity(intent);
        });
    }
}
